package com.jeeplus.test.jlnu.student.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeeplus.test.jlnu.student.domain.entity.BkStudentGraduate;
import com.jeeplus.test.jlnu.student.mapper.BkStudentGraduateMapper;
import com.jeeplus.test.jlnu.student.service.BkStudentGraduateService;
import com.jeeplus.test.tools.resp.Convert2Bean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BkStudentGraduateServiceImpl extends ServiceImpl<BkStudentGraduateMapper, BkStudentGraduate> implements BkStudentGraduateService {
    @Autowired
    private BkStudentGraduateMapper bkStudentGraduateMapper;

    @Override
    public BkStudentGraduate getBkStudentGraduate(String studentId) {
        LambdaQueryChainWrapper<BkStudentGraduate> wrapper = new LambdaQueryChainWrapper<>(bkStudentGraduateMapper);
        wrapper.eq(BkStudentGraduate::getStudentId, studentId);
        return wrapper.one();
    }

    @Override
    public Boolean bkStudentGraduateUpdate(BkStudentGraduate bkStudentGraduate) {
        LambdaUpdateChainWrapper<BkStudentGraduate> wrapper = new LambdaUpdateChainWrapper<>(bkStudentGraduateMapper);
        if (ObjectUtil.isNotEmpty(bkStudentGraduate.getGraduationDate())){
            wrapper.set(BkStudentGraduate::getGraduationDate,bkStudentGraduate.getGraduationDate());
        }
        if (ObjectUtil.isNotEmpty(bkStudentGraduate.getGraduationDestination())){
            wrapper.set(BkStudentGraduate::getGraduationDestination,bkStudentGraduate.getGraduationDestination());
        }
        if (ObjectUtil.isNotEmpty(bkStudentGraduate.getEducationLevel())){
            wrapper.set(BkStudentGraduate::getEducationLevel,bkStudentGraduate.getEducationLevel());
        }
        if (ObjectUtil.isNotEmpty(bkStudentGraduate.getDegreeStatus())){
            wrapper.set(BkStudentGraduate::getDegreeStatus,bkStudentGraduate.getDegreeStatus());
        }
        if (ObjectUtil.isNotEmpty(bkStudentGraduate.getForeignLanguage())){
            wrapper.set(BkStudentGraduate::getForeignLanguage,bkStudentGraduate.getForeignLanguage());
        }
        if (ObjectUtil.isNotEmpty(bkStudentGraduate.getInternshipUnit())){
            wrapper.set(BkStudentGraduate::getInternshipUnit,bkStudentGraduate.getInternshipUnit());
        }
        if (ObjectUtil.isNotEmpty(bkStudentGraduate.getInternshipContent())){
            wrapper.set(BkStudentGraduate::getInternshipContent,bkStudentGraduate.getInternshipContent());
        }
        if (ObjectUtil.isNotEmpty(bkStudentGraduate.getGraduationDesign())){
            wrapper.set(BkStudentGraduate::getGraduationDesign,bkStudentGraduate.getGraduationDesign());
        }
        if (ObjectUtil.isNotEmpty(bkStudentGraduate.getOtherInformation())){
            wrapper.set(BkStudentGraduate::getOtherInformation,bkStudentGraduate.getOtherInformation());
        }
        if (ObjectUtil.isNotEmpty(bkStudentGraduate.getPersonalEvaluation())){
            wrapper.set(BkStudentGraduate::getPersonalEvaluation,bkStudentGraduate.getPersonalEvaluation());
        }
        wrapper.eq(BkStudentGraduate::getId, bkStudentGraduate.getId());
        return wrapper.update();
    }
}
